package com.ant.storage.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author hzd
 * @version 1.0
 * @date 2023/8/5 11:02
 */
public class downloadTemplate {

    //https://blog.csdn.net/Jul_C18672868641/article/details/129022583
//    public BaseResponse<?> downloadTemplate(HttpServletResponse response,String tempName) throws Exception {
//        response.setCharacterEncoding("UTF-8");
//        response.setHeader("Content-disposition", tempName);
//        List<List<String>> header = head();
//        EasyExcel.write(response.getOutputStream())
//                .head(header)
//                .sheet(tempName).doWrite(Collections.EMPTY_LIST);
//        return BaseResponse.success(true);
//    }
    /**
     * 下载模板的自定义表头
     * @return
     */
    private static List<List<String>> head() {
        List<List<String>> list = new ArrayList<>();
        List<String> head0 = new ArrayList<>();
        head0.add("序号");
        list.add(head0);
        Map<String, List<String>> map = getHeader();
        map.forEach((k, v) -> {
            String deviceCategory = k;
            List<String> ls = v;
            ls.forEach(e -> {
                List<String> head = new ArrayList<>();
                head.add(deviceCategory);
                head.add(e);
                list.add(head);
            });

        });
        List<String> head1 = new ArrayList<>();
        head1.add("备注");
        list.add(head1);
        List<String> head2 = new ArrayList<>();
        head2.add("埋深");
        list.add(head2);
        return list;
    }
    /**
     * 下载模板的自定义表头第二行
     * @return
     */
    private static Map<String, List<String>> getHeader() {
        Map<String, List<String>> map = new HashMap<>();
        List<String> aList = new ArrayList<>();
        List<String> sList = new ArrayList<>();
        List<String> subList = new ArrayList<>();
        String column1 = "X";
        aList.add(column1);
        String column2 = "Y";
        aList.add(column2);
        String column3 = "B";
        sList.add(column3);
        String column4 = "L";
        sList.add(column4);
        String subColumn = "其它";
        subList.add(subColumn);
        subList.add("小计3");
        map.put("坐标", aList);
        map.put("经纬度", sList);
        return map;
    }

}
